package com.example.gcjjhd.agriculture.service;

import com.example.gcjjhd.agriculture.entity.Device;
import com.example.gcjjhd.agriculture.repository.DeviceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class DeviceService {
    @Autowired
    private DeviceRepository deviceRepository;

    public List<Device> getAllDevices() {
        return deviceRepository.findAll();
    }

    public Device getDeviceById(String id) {
        return deviceRepository.findById(id).orElse(null);
    }

    public List<Device> getDevicesByType(String type) {
        return deviceRepository.findByType(type);
    }
}